CREATE TABLE [dbo].[tb_TiposDeEspacio]
(
[idTipoDeEspacio] [int] NOT NULL IDENTITY(1, 1),
[Descripcion] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
) ON [PRIMARY]
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE TRIGGER [dbo].[updateTipoEspacios] ON [dbo].[tb_TiposDeEspacio] 
FOR UPDATE
AS

if (update(idTipoDeEspacio)) begin
	UPDATE tb_Espacios
	SET TipoDeEspacio = (SELECT idTipoDeEspacio from inserted)
	WHERE TipoDeEspacio in (SELECT idTipoDeEspacio from deleted)
end
GO
ALTER TABLE [dbo].[tb_TiposDeEspacio] ADD CONSTRAINT [PK_tb_TiposDeEspacio] PRIMARY KEY NONCLUSTERED  ([idTipoDeEspacio]) ON [PRIMARY]
GO
